﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using SoftwareConsulting.BI11.Studio.Core.Project.Metadata;
using SoftwareConsulting.BI11.Studio.UI.Properties;
using SoftwareConsulting.BI11.Studio.InternalServices;

namespace SoftwareConsulting.BI11.Studio.UI.ProjectExplorer.Extensions
{
    /// <summary>
    /// Класс расширяющих функций работы с проектом
    /// </summary>
    public static class Extensions            
    {
        /// <summary>
        /// Возвращает подсказку по информации об объекте метаданных
        /// </summary>
        /// <param name="descriptor"></param>
        /// <returns></returns>
        public static string GetObjectTip(this IMetadataObjectDescriptor descriptor)
        {
            return descriptor.Kind.GetObjectTip();
        }

        /// <summary>
        /// Возвращает подсказку по виду объекта метаданных
        /// </summary>
        /// <param name="kind"></param>
        /// <returns></returns>
        public static string GetObjectTip(this MetadataObjectKind kind)
        {
            string tip = "";
            switch (kind)
            {
                case MetadataObjectKind.Folder:
                    tip = Resources.BI_PROJECTEXPLORER_KINDS_TIPS_FOLDER;
                    break;
                case MetadataObjectKind.Indicator:
                    tip = Resources.BI_PROJECTEXPLORER_KINDS_TIPS_INDICATOR;
                    break;
                case MetadataObjectKind.Situation:
                    tip = Resources.BI_PROJECTEXPLORER_KINDS_TIPS_SITUATION;
                    break;
                case MetadataObjectKind.Table:
                    tip = Resources.BI_PROJECTEXPLORER_KINDS_TIPS_TABLE;
                    break;
                case MetadataObjectKind.Dimension:
                    tip = Resources.BI_PROJECTEXPLORER_KINDS_TIPS_DIMENSION;
                    break;
                case MetadataObjectKind.Cube:
                    tip = Resources.BI_PROJECTEXPLORER_KINDS_TIPS_CUBE;
                    break;
                case MetadataObjectKind.TimeSeries:
                    tip = Resources.BI_PROJECTEXPLORER_KINDS_TIPS_TIMESERIES;
                    break;
                case MetadataObjectKind.Model:
                    tip = Resources.BI_PROJECTEXPLORER_KINDS_TIPS_MODEL;
                    break;
                case MetadataObjectKind.Calculation:
                    tip = Resources.BI_PROJECTEXPLORER_KINDS_TIPS_CALCULATION;
                    break;
                case MetadataObjectKind.ClassificationProblem:
                    tip = Resources.BI_PROJECTEXPLORER_KINDS_TIPS_CLASSIFICATIONPROBLEM;
                    break;
                case MetadataObjectKind.ActionSet:
                    tip = Resources.BI_PROJECTEXPLORER_KINDS_TIPS_ACTIONSET;
                    break;
                case MetadataObjectKind.Shortcut:
                    tip = Resources.BI_PROJECTEXPLORER_KINDS_TIPS_SHORTCUT;
                    break;
                default:
                    Assert.Fail(Assert.Id.Assert00142);
                    break;
            }
            return tip;
        }

        /// <summary>
        /// Устанавливает заголовок просматривателя объекта
        /// </summary>
        /// <param name="form"></param>
        /// <param name="obj"></param>
        public static void SetObjectViewerCaption(this Form form, string viewerName, object obj)
        {
            form.Text = string.Format("{0} - {1}", viewerName, obj.ToString());
        }
    }
}
